home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
btsys.arc
/
BTIRED.C
< prev
next >
Wrap
Text File
|
1984-12-14
|
1KB
|
61 lines
/* btired */
#include <stdio.h>
#include <btextern.h>
int btired (filhand, key)
int filhand;
char key[];
/* random read function */
{
int i, j, k, occurs, klength, recno;
char *cp;
printf("BTIRED filhand %d key %s\n", filhand, key);
klength = btfilar[filhand].keylen; /* get key length */
occurs = (LBLEN - 1) / (klength + 3);
recno = btfilar[filhand].root;
/* get root record */
if ((i = btread (filhand, recno)))
BTSETCOD (filhand, recno, i); /* set read error */
/* start looping forever */
while (1) {
if (*((char *)btfilar[filhand].filbuf + (LBLEN -1)) == 'N') {
ip1 = btfilar[filhand].filbuf;
cp1 = (char *)(btfilar[filhand].filbuf + occurs);
while ((i = strcmp (cp1, "")) != 0
&& (k = strcmp (cp1, key)) == -1)
{
ip1++;
cp1 += (klength + 1);
}
recno = *ip1;
if ((i = btread (filhand, recno)))
BTSETCOD (filhand, recno, i); /* set read error */
}
else {
j = 0;
ip1 = btfilar[filhand].filbuf;
cp1 = btfilar[filhand].ikeyptr;
while (*ip1 != NULL) {
if ((i = strcmp (cp1, key)) == 0) {
gdatapt = *ip1;
return (0);
}
else {
ip1++;
cp1 += (klength + 1);
}; /* end else */
};
return (-1);
}; /* end else */
} /* end while */
} /* end btired */